<template>
  <div class="app-container">
    <eHeader :param-bean="paramBean" :sup_this="sup_this" />
    <!--表格渲染-->
    <DataGridTable
      v-loading="loading"
      ref="mainTable"
      :sup_this="sup_this"
      :data="data.rtnList"
      :max-height="gridMaxHeight"
      :total="total"
      :all-define-columns="['sysOrgName','busOtherCpyName','busDate','itemCode','itemName','itemSpec','unit','sampleQty','processStatus','qcCheckResult','sourceCode','busUserName','lastUpdateDate','sourceDetailLotNo','orderCode','poCode']"
      grid-id="qcWaitMngProcessGridId"
      @selection-change="handleGridSelectionChange">
      <DataGridColumn slot="sysOrgName" prop="sysOrgName" label="机构" />
      <DataGridColumn slot="busOtherCpyName" prop="busOtherCpyName" label="供应商"/>
      <DataGridColumnSlot slot="busDate" prop="busDate" label="业务时间">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.busDate) }}</span>
        </template>
      </DataGridColumnSlot>
      <DataGridColumn slot="itemCode" prop="itemCode" label="物料编号" />
      <DataGridColumn slot="itemName" prop="itemName" label="名称" />
      <DataGridColumn slot="itemSpec" prop="itemSpec" label="规格" />
      <DataGridColumnSlot slot="unit" prop="unit" label="单位">
        <template slot-scope="scope">
          <template v-for="item in dicts.item_unit">
            <span v-if="scope.row.unit && scope.row.unit === item.dictCode" :key="item.id" >{{ item.dictName }}</span>
          </template>
        </template>
      </DataGridColumnSlot>
      <DataGridColumn slot="sampleQty" prop="sampleQty" label="批次数" />
      <DataGridColumnSlot slot="processStatus" prop="processStatus" label="检验状态">
        <template slot-scope="scope">
          <template v-for="item in dicts.qc_process_status">
            <el-tag v-if="scope.row.processStatus === item.dictCode" :key="item.id" :type="item.attribute1" >{{ item.dictName }}</el-tag>
          </template>
        </template>
      </DataGridColumnSlot>
      <DataGridColumnSlot slot="qcCheckResult" prop="qcCheckResult" label="检验结果">
        <template slot-scope="scope">
          <template v-for="item in dicts.qc_result">
            <el-tag v-if="scope.row.qcCheckResult === item.dictCode" :key="item.id" :type="item.attribute1" >{{ item.dictName }}</el-tag>
          </template>
        </template>
      </DataGridColumnSlot>
      <DataGridColumn slot="sourceCode" prop="sourceCode" label="入库/生产单号" />
      <DataGridColumn slot="busUserName" prop="busUserName" label="业务员" />
      <DataGridColumnSlot slot="lastUpdateDate" prop="lastUpdateDate" label="最后更新时间" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdateDate) }}</span>
        </template>
      </DataGridColumnSlot>
      <DataGridColumn slot="sourceDetailLotNo" prop="sourceDetailLotNo" label="入库/生产明细批号" />
      <DataGridColumn slot="orderCode" prop="orderCode" label="订单号" />
      <DataGridColumn slot="poCode" prop="poCode" label="采购单号" />
    </DataGridTable>
  </div>
</template>

<script>
import { parseTime } from '@/utils/index'
import eHeader from './module/header'
import initData from '@/mixins/initData'
import qcWait from '@/api/prod/QcWait'

export default {
  components: { eHeader },
  dictTypes: ['qc_process_status', 'item_unit', 'qc_result'],
  mixins: [initData],
  props: {
  },
  data() {
    return {
      delLoading: false,
      sup_this: this
    }
  },
  created() {
    this.url = qcWait.loadDataUrl()
    this.defaultParamBean.processStatus = 'wait'
    this.$nextTick(() => {
      this.resetQuery(true)
    })
  },
  mounted() {
  },
  methods: {
    parseTime,
    async beforeInit() {
      return true
    }
  }
}
</script>
